package com.proxyhub.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Pattern;

/**
 * Created by linxsh on 2017/6/15.
 */
public class CommonUtil {
    public final static String USERAGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36";

    public final static String UTF8 = "UTF-8";
    public final static String GBK = "GBK";

    private final static Pattern IPREGEX = Pattern.compile("((?:(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d))))");

    public static boolean isIP(String ip) {
        if(StringUtils.isBlank(ip)) {
            return false;
        }
        return IPREGEX.matcher(ip).matches();
    }
}
